home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / comm / net / tf02.lha / TinyFugue / tf-lib / map.tf < prev    next >
Text File  |  1995-08-12  |  2KB  |  77 lines

  1. ;;;; Mapping.
  2. ;;;; This file implements mapping and movement ("speedwalking") commands
  3. ;;;; similar to those found in tintin.  Once mapping is enabled with /mark,
  4. ;;;; all movement commands (n,s,e,w,ne,sw,nw,se,u,d) will be remembered in
  5. ;;;; your "path".
  6.  
  7. ;;;; usage:
  8. ;;; /map <dir>        Add <dir> to remembered path.
  9. ;;; /mark        Reset path and enable mapping.
  10. ;;; /path        Display remembered path.
  11. ;;; /return        Move in the opposite direction of the last remembered
  12. ;;;              movement, and remove that last movement from the path.
  13. ;;; /savepath <name>    Create a macro <name> to execute the current path.
  14. ;;;              Note: macro is not written to a file.
  15. ;;; /unpath        Remove the last movement from the path.
  16. ;;; /unmark        Disable maping.
  17. ;;; /dopath <path>    Execute <path>, where <path> is a space-separated list
  18. ;;;              of commands with optional repeat counts.  E.g.,
  19. ;;;              "/dopath 10 n 3 e d 2 w" will execute "n" 10
  20. ;;;              times, "e" 3 times, "d" once, and "w" twice.
  21.  
  22. /~loaded map.tf
  23.  
  24. /set path=
  25.  
  26. /def -i mark = \
  27.     /echo %% Will start mapping here.%;\
  28.     /set path=%;\
  29. ;       note: _map_hook can also be called from speedwalk.tf.
  30.     /def -iFp9999 -mglob -h'send {n|s|e|w|ne|sw|nw|se|u|d}' _map_hook = \
  31.             /map %%*%;\
  32. ;       _map_send catches and sends anything _map_hook caught, unless there was
  33. ;       a non-fall-thru hook of intermediate priority that blocked it.
  34.     /def -i -mglob -h'send {n|s|e|w|ne|sw|nw|se|u|d}' _map_send = \
  35.             /send %%*
  36.  
  37. /def -i map    = /set path=%path %1
  38.  
  39. /def -i unmark    =\
  40.     /set path=%;\
  41.     /undef _map_hook%;\
  42.     /undef _map_send%;\
  43.     /echo %% Mapping disabled.
  44.  
  45. /def -i path    = /echo %% Path: %path
  46.  
  47. /def -i savepath= /def -i %1 = /dopath %path
  48.  
  49. /def -i dopath    = \
  50.     /if ( {1} =/ '[0-9]*' & {#} >= 2 ) \
  51.         /for i 1 %1 %2%;\
  52.         /dopath %-2%;\
  53.     /elseif ({#}) \
  54.         %1%;\
  55.         /dopath %-1%;\
  56.     /endif
  57.  
  58. /def -i unpath    = /set path=$(/all_but_last %path)
  59.  
  60. /def -i return = \
  61.     /let dir=$(/last %path)%;\
  62.     /unpath%;\
  63. ;       These directions must be listed in complementary pairs.
  64.     /_return_aux n s e w ne sw nw se u d%;
  65.  
  66. /def -i _return_aux = \
  67.     /if ( {#} == 0 ) \
  68.         /echo %% Don't know how to return from "%dir".%;\
  69.         /set path=%path %dir%;\
  70.     /elseif ( dir =~ "%1" ) /send - %2%;\
  71.     /elseif ( dir =~ "%2" ) /send - %1%;\
  72.     /else   /_return_aux %-2%;\
  73.     /endif
  74.  
  75.  
  76. /def -i all_but_last = /echo - %-L
  77.